﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.Models;
using SWDataDB.BLL;
using SWDataDB.DAL;
using System.Data;
 



public partial class AdminManage_Edit_YPEdit : System.Web.UI.Page
{
    public string ypid = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        ypid = Request["ypid"];
        bind();
    }


    private void bind()
    {
        YPInfo ypquery = new YPInfo();
        int YPID = Convert.ToInt32(ypid);
        DataSet ds = ypquery.SelectByYPID(ypid);
        DataRowView dv = ds.Tables[0].DefaultView[0];


        YP_CODE.Text = Convert.ToString(dv.Row["YP_CODE"]);
        YP_NAME.Text = Convert.ToString(dv.Row["YP_NAME"]);
        PM_PATH_NAME.Text = Convert.ToString(dv.Row["PM_PATH_NAME"]);
        PM_PATH_NUM.Text = Convert.ToString(dv.Row["PM_PATH_NUM"]);
        GEO_ATT_NUM.InnerText = Convert.ToString(dv.Row["GEO_ATT_NUM"]);


        YP_LAT_D.Text = Convert.ToString(dv.Row["YP_LAT"]).Substring(0, 3);
        YP_LAT_F.Text = Convert.ToString(dv.Row["YP_LAT"]).Substring(3, 2);
        YP_LAT_M.Text = Convert.ToString(dv.Row["YP_LAT"]).Substring(5);
        YP_LON_D.Text = Convert.ToString(dv.Row["YP_LON"]).Substring(0, 2);
        YP_LON_F.Text = Convert.ToString(dv.Row["YP_LON"]).Substring(2, 2);
        YP_LON_M.Text = Convert.ToString(dv.Row["YP_LON"]).Substring(4);


        YP_STYLE.Text = Convert.ToString(dv.Row["YP_STYLE"]);
        STYLE_CODE.Text = Convert.ToString(dv.Row["STYLE_CODE"]);
        BP_ID.Text = Convert.ToString(dv.Row["BP_ID"]);
        OUT_NAME.Text = Convert.ToString(dv.Row["OUT_NAME"]);



        INNAR_NAME.Text = Convert.ToString(dv.Row["INNAR_NAME"]);
       
        IMAGE.Text = Convert.ToString(dv.Row["IMAGE"]);//行政区划
        REMARK.InnerText = Convert.ToString(dv.Row["REMARK"]);
        CY_POS.Text = Convert.ToString(dv.Row["CY_POS"]);
        CY_LEVEL.Text = Convert.ToString(dv.Row["CY_LEVEL"]);

        CJ_PEOPLE.Text = Convert.ToString(dv.Row["CJ_PEOPLE"]);
        CJ_DATE.Text = Convert.ToString(dv.Row["CJ_DATE"]);


        ZL_FILE_ID.Text = Convert.ToString(dv.Row["ZL_FILE_ID"]);
        //从著录表中读取title
        ZLInfo ZLFILEID = new ZLInfo();
        ZL_TBL zl = ZLFILEID.SelectZLInfoByID(dv.Row["ZL_FILE_ID"].ToString());
        TITLE_.Text = zl.O_TITLE;
        FileTitle.Text = zl.O_TITLE;
    }


    protected void submit_Click(object sender, EventArgs e)
    {
        YP_INFO_TBL ypobj = new YP_INFO_TBL();
        YPInfo kc_in = new YPInfo();

        ypobj.O_YP_CODE = Request.Form["YP_CODE"];
        ypobj.O_YP_NAME = Request.Form["YP_NAME"];

        ypobj.O_PM_PATH_NAME = Request.Form["PM_PATH_NAME"];
        ypobj.O_PM_PATH_NUM = Request.Form["PM_PATH_NUM"];

        ypobj.O_GEO_ATT_NUM = this.GEO_ATT_NUM.InnerText;

        ypobj.O_YP_LAT = int.Parse((Request.Form["YP_LAT_D"] + Request.Form["YP_LAT_F"] + Request.Form["YP_LAT_M"]));
        ypobj.O_YP_LON = int.Parse((Request.Form["YP_LON_D"] + Request.Form["YP_LON_F"] + Request.Form["YP_LON_M"]));


        ypobj.O_YP_STYLE = Request.Form["YP_STYLE"];





        ypobj.O_STYLE_CODE = Request.Form["STYLE_CODE"];

        ypobj.O_BP_ID = Request.Form["BP_ID"];
        ypobj.O_OUT_NAME = Request.Form["OUT_NAME"];
        
        //yxobj.O_IMAGE = float.Parse((Request.Form["IMAGE"];

        ypobj.O_INNAR_NAME = Request.Form["INNAR_NAME"];
        ypobj.O_REMARK = this.REMARK.InnerText;

        ypobj.O_CY_POS = Request.Form["CY_POS"];
        ypobj.O_CY_LEVEL = Request.Form["CY_LEVEL"];
        ypobj.O_CJ_PEOPLE = Request.Form["CJ_PEOPLE"];
        ypobj.O_CJ_DATE = Request.Form["CJ_DATE"];

        ypobj.O_ZL_FILE_ID = Request.Form["ZL_FILE_ID"];


        ypobj.O_ID = int.Parse(ypid);






        if (kc_in.UpdateYPInfo(ypobj) == 1)
        {
            //bind();
            Response.Write("<script language=javascript>alert('更新成功！');location='../Manage/YPManage.aspx'</script>");
            //Response.Redirect("ZLManage.aspx");
        }
        else
        {
            Response.Write("<script language=javascript>alert('更新失败！');location='../Manage/YPManage.aspx'</script>");
        }
    }
}